<template>
  <div>
      <h1>分类添加</h1>
      <p>分类名：<input type="text" v-model="name"></p>
      <p><el-button type="primary" @click="sub">添加</el-button></p>
  </div>
</template>

<script>
import axios from 'axios';
export default {
     data(){
        return {
            name:'',
            base_url:'http://127.0.0.1:8000'
        }
    },
    methods:{
        sub(){
            console.log(this.name)
            let form_data = new FormData()
            form_data.append('name',this.name)
            axios({
                url: this.base_url + '/app01/cate',
                method:'post',
                data:form_data
            }).then(res=>{
                console.log(res.data)
                alert(res.data.msg)
                }).catch(error=>{
                    console.log(error)
                })
        },

    }
}
</script>

<style>

</style>